<?php
class NavVars
{
    static public function getNavVars($check=TRUE)
    {
        $pag = isset($_GET["pag"])?$_GET["pag"]:1;
        $ord = isset($_GET["ord"])?$_GET["ord"]:1;  
        $sen = isset($_GET["sen"])?$_GET["sen"]:1; 
        
        if ($check === TRUE)
        {
            $pag = self::getNumeric($pag,1,999999,"1");
            $ord = self::getNumeric($ord,1,99,"1"); 
            $sen = self::getNumeric($sen,1,2,"1"); 
        }
    
        return array($pag,$ord,$sen);        
    }
    
    static public function getNumeric($value,$minvalue,$maxvalue,$default = "1")
    {
        if ($value == "") 
            return $minvalue;
        if (!is_numeric($value))
            return $default;
        if ($value < $minvalue)
            return $minvalue;
        if ($value > $maxvalue)
            return $maxvalue;
        return $value;
    }
    
    static public function getPostVars($postVars, $prefix)
    {
        $POSTVARS = (object) array();
        foreach ($postVars as $key => $val)
        {
            if (strstr($key,$prefix)==0)
            {
                $key2 = substr($key,strlen($prefix));
                $POSTVARS->$key2 = addslashes(stripslashes(stripslashes($val)));
            }
        }
        return $POSTVARS;
    }
}
?>